export function pieChart(data, options){//折线图
    var echarts = require('echarts');
    // let  data1= JSON.parse(JSON.stringify(data));
    var series = [];
    for(var i = 0;i<options.legend.length;i++){
        if(i===0){
            series.push({
                name: options['legend'][i],
                data: data['data'+i],
                type: 'line',
                smooth: options['smooth'] || ''
            })
        }else{
            series.push({
                name: options['legend'][i],
                data: data['data'+i],
                type: 'line',
                smooth: options['smooth'] || ''
            })
        }
    }
   
    var option = {
        title: options['title'],
        backgroundColor: options['backgroundColor'],
        tooltip: {
            trigger: 'item',
            formatter: '{a} <br/>{b} : {c} ({d}%)'
            // formatter: options['formatter']
        },
        legend: {
            orient: 'vertical',
            left: 'left',
            // selectedMode: false,//禁用图例取消点击事件
            data: options['legend']
        },
        series: [
            {
                name: '',
                type: 'pie',
                avoidLabelOverlap: true,
                radius: '70%',
                center: ['50%', '50%'],
                data: data['data0'],              
                emphasis: {
                    itemStyle: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                },
                label: options['label']? options['label'] :{formatter:'{b}:{c}'},
            }
        ]
    };
    options['color'] ?option['color'] = options['color']: '';
    options['tooltip'] ?option['tooltip'] = options['tooltip']: '';
    if(!document.getElementById(options['id'])){return false;}
    let myChart = echarts.init(document.getElementById(options['id']), options['theme']? options['theme']: '');
    // 页面大小发生改变时Echarts也跟着发生改变
    myChart.resize();
	myChart.clear();
	myChart.setOption(option);
}
export default pieChart = pieChart;







